package com.zixinokhttp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.fly.okhttp.base.BaseOKHttpResultCallBack;
import com.fly.okhttp.param.OKHttpParams;
import com.fly.okhttp.util.OKHttpUtil;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {
    @OnClick(R.id.button) void submit() {
        OKHttpParams params = new OKHttpParams();
        params.put("voyage_code", "10007");
        OKHttpUtil.postAsync(this,"http://3.ferry.shop:84?r=boardingapi/boarding/getmembership",params, new BaseOKHttpResultCallBack() {
            @Override
            public void noInternet() {
                Log.e("tag", "没有网络");
            }

            @Override
            public void onFailure(Exception e) {
                Log.e("tag", "失败 " + e.getMessage());
            }

            @Override
            public void onResponse(String result) {
                Log.e("tag", result);
                Toast.makeText(MainActivity.this,""+result+"", Toast.LENGTH_LONG).show();
            }
        });
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
    }
}
